﻿Public Class formsetting

    Private Sub formsetting_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        process.Timer1.Interval = 1500
        process.ShowDialog()
        Me.txtactinative.BackColor = My.Settings.DataGridViewAlternativeColor
        Me.txtrowhight.Text = My.Settings.DataGridViweRowHeight
        Me.txtfontname.Font = My.Settings.DataGridViweFont
        Me.cbolangguage.Text = My.Settings.langauage
        'time--------------
        Me.cboM_in_hh.Text = My.Settings.M_IN_HH
        Me.cbom_in_mm.Text = My.Settings.M_IN_MM
        Me.cbom_out_hh.Text = My.Settings.M_OUT_HH
        Me.cbom_out_mm.Text = My.Settings.M_OUT_MM
        Me.cbom_stop_hh.Text = My.Settings.M_STOP_HH
        Me.cbom_stop_mm.Text = My.Settings.M_STOP_MM
        Me.cboa_in_hh.Text = My.Settings.A_IN_HH
        Me.cboa_in_mm.Text = My.Settings.A_IN_MM
        Me.cboa_out_hh.Text = My.Settings.A_OUT_HH
        Me.cboa_out_mm.Text = My.Settings.A_OUT_MM
        Me.cboa_stop_hh.Text = My.Settings.A_STOP_HH
        Me.cboa_stop_mm.Text = My.Settings.A_STOP_MM
    End Sub

    Private Sub txtactinative_MouseClick(sender As Object, e As MouseEventArgs) Handles txtactinative.MouseClick
        Dim cd As New ColorDialog()
        cd.Color = Me.txtactinative.BackColor
        If (cd.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            Me.txtactinative.BackColor = cd.Color
        End If
    End Sub
    Private Sub txtactinative_TextChanged(sender As Object, e As EventArgs) Handles txtactinative.TextChanged

    End Sub

    Private Sub txtfontname_MouseClick(sender As Object, e As MouseEventArgs) Handles txtfontname.MouseClick
        Dim fd As New FontDialog()
        fd.Font = Me.txtfontname.Font
        If fd.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.txtfontname.Font = fd.Font
        End If
    End Sub

    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click
        My.Settings.DataGridViewAlternativeColor = Me.txtactinative.BackColor
        My.Settings.DataGridViweRowHeight = Me.txtrowhight.Text
        My.Settings.DataGridViweFont = Me.txtfontname.Font
        My.Settings.langauage = Me.cbolangguage.Text
        My.Settings.Save()
        Form1.loadatd()
        Form1.loademployee()
        Form1.loadholiday()
        Form1.loaduser()
        Me.Close()
    End Sub

    Private Sub ButtonX3_Click(sender As Object, e As EventArgs) Handles ButtonX3.Click
        My.Settings.M_IN_HH = Me.cboM_in_hh.Text
        My.Settings.M_IN_MM = Me.cbom_in_mm.Text
        My.Settings.M_OUT_HH = Me.cbom_out_hh.Text
        My.Settings.M_OUT_MM = Me.cbom_out_mm.Text
        My.Settings.M_STOP_HH = Me.cbom_stop_hh.Text
        My.Settings.M_STOP_MM = Me.cbom_stop_mm.Text
        My.Settings.A_IN_HH = Me.cboa_in_hh.Text
        My.Settings.A_IN_MM = Me.cboa_in_mm.Text
        My.Settings.A_OUT_HH = Me.cboa_out_hh.Text
        My.Settings.A_OUT_MM = Me.cboa_out_mm.Text
        My.Settings.A_STOP_HH = Me.cboa_stop_hh.Text
        My.Settings.A_STOP_MM = Me.cboa_stop_mm.Text
        My.Settings.Save()
        Me.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CMD.Parameters("@id") = Formlogin.txtemp_id.Text.Trim
        Dim pwd = CMD.ExecuteScalar("select PWD from TBL_USER WHERE EMP_ID=@id")
        If txtoldpwd.Text.Trim = "" Then
            MsgBox("Please Input Your Old Password....!")
            txtoldpwd.Focus()
            Exit Sub
        End If
        If txtnewpwd.Text.Trim = "" Then
            MsgBox("Please Input a New password ....!")
            txtnewpwd.Focus()
            Exit Sub
        End If
        If txtconfirm.Text.Trim = "" Then
            MsgBox("Please Confirm Your password.....!")
            txtconfirm.Focus()
            Exit Sub

        End If
        If txtnewpwd.Text.Trim <> txtconfirm.Text.Trim Then
            MsgBox("Your Password confirm not Match.....!")
            txtconfirm.SelectAll()
            Exit Sub
        End If
        If txtoldpwd.Text.Trim = pwd Then
            CMD.Parameters("@pwd") = txtnewpwd.Text.Trim
            CMD.ExecuteNonQuery("UPDATE TBL_USER SET PWD=@pwd")
            txtoldpwd.Clear()
            txtnewpwd.Clear()
            txtconfirm.Clear()
            Me.Close()
            MsgBox("Password has been change Success....!")
        Else
            MsgBox("Your Old Password is Incorrect....!")
        End If
    End Sub

End Class